package day15;

import java.util.concurrent.*;

import static java.awt.PageAttributes.MediaType.C1;

public class CallableDemo {
    public static void main(String[] args) {
        ExecutorService executor= Executors.newCachedThreadPool();
        C1 c=new C1();
        FutureTask<Integer>future=new FutureTask<>(c);
        executor.submit(future);
        executor.shutdown();
        try {
            Integer result=future.get();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }


    }
}
class  C1 implements Callable<Integer>{

    @Override
    public Integer call() {
        System.out.println("zi");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        int sum=0;
        for (int i = 0; i <100 ; i++) {
            sum+=i;

        }
        return sum;
    }
}